package memento.improve;

import lombok.Data;

/**
 * 发起者
 */
@Data
public class Originator {
    private String name;
    private int vit;
    private int def;

    public Originator(String name, int vit, int def) {
        this.name = name;
        this.vit = vit;
        this.def = def;
        System.out.println("当前角色为:" + name + "，攻击力为:" + vit + "，防御力为:" + def);
    }

    // 保存到备忘录
    public Memento saveToMemento() {
        return new Memento(vit, def);
    }

    // 从备忘录恢复
    public void restoreFromMemento(Memento memento) {
        this.vit = memento.getVit();
        this.def = memento.getDef();
        System.out.println("当前角色为:" + name + "，攻击力为:" + vit + "，防御力为:" + def);
    }
}
